package com.minelx.woods.pc.service;

import com.alibaba.fastjson.JSONObject;
import com.minelx.httpclient.core.request.IResponse;
import com.minelx.woods.pc.form.values.VariantValues;
import com.minelx.woods.pc.service.mapper.ReviewRequestMapper;

import java.util.List;

public class ReviewService {
	private final ReviewRequestMapper reviewRequestMapper;

	private final String token;

	public ReviewService(ReviewRequestMapper reviewRequestMapper, String token) {
		this.reviewRequestMapper = reviewRequestMapper;
		this.token = token;
	}

	public IResponse postReview(String sourceType,
	                            String reviewName,
	                            List<String> reviewers,
	                            JSONObject sourceVariables,
	                            String[] collections,
	                            VariantValues[] variantCollections) {
		return reviewRequestMapper.requestPostReview(
				token,
				reviewName,
				reviewers,
				sourceType,
				sourceVariables,
				collections,
				variantCollections);
	}

	public IResponse getReviews(int offset, int length) {
		return reviewRequestMapper.requestGetReviews(token, offset, length);
	}

	public IResponse approve(String reviewId) {
		return reviewRequestMapper.requestApprove(token, reviewId);
	}

	public IResponse reject(String reviewId) {
		return reviewRequestMapper.requestReject(token, reviewId);
	}
}
